package core.genetic;

import java.util.ArrayList;

import core.*;

import utility.Pair;

public class Population
{
	private ArrayList<Individual> individuals;
	
	public Population(int genesize){
		individuals = new ArrayList<Individual>();
		for(int i = 0;i<Mode.mode.popSize;i++)
			individuals.add(Individual.createRandom(genesize));
	}
	
	public Individual get(int i){
		return individuals.get(i);
	}
	
	public void set(int i, Individual ind){
		individuals.set(i, ind);
	}

	public int size() {
		return individuals.size();
	}
	
	public void setFirst(Pair<Individual,Double>[] par, int length){
		for (int i=0; i<length; i++){
			this.set(i, par[i].first());
		}
	}

	public Individual[] getIndividuals() {
		return individuals.toArray(new Individual[individuals.size()]);
	}
}
